I=imread('4.jpg');
th=graythresh(I);       
J=im2bw(I,th);     
subplot(121),imshow(I);   
subplot(122),imshow(J); 